package com.cssw.fyzb.busi.api.video;

import com.cssw.fyzb.core.model.vo.video.VideoCommentVo;
import com.cssw.fyzb.busi.service.im.ImService;
import com.cssw.fyzb.busi.service.video.VideoService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 查询喜欢的视频列表
 *
 * @author YangYiQun
 */
@Function(description = "点赞视频评论", parameters = {
        @Parameter(name = "commentId", type = Type.Integer, description = "评论标识", required = true),
        @Parameter(name = "userId", type = Type.Integer, description = "用户标识", required = true)
})
@Component
public class LikeVideoComment implements Action {

    @Autowired
    private VideoService videoService;

    @Autowired
    private ImService imService;

    private static final Logger logger = LoggerFactory.getLogger(LikeVideoComment.class);

    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");
        Long commentId = request.getLong("commentId");
        try {
            videoService.likeComment(userId, commentId);

            imService.sendLikeCommentMsg(userId, commentId);

            return Response.success();
        } catch (Exception e) {
            logger.info("", e);
            return Response.fail("操作异常");
        }
    }

}
